/**
 * 
 */
Ext.onReady(function () {
	
	Ext.QuickTips.init();
	
	var menuPanel = new Ext.Panel({
		xtype: "panel",
		title: "管理菜单",
		region: 'west',
		collapsible: true,
		autoScroll: true,
	    split: true,
		width: 200,
		layout: "accordion"
	});
	
	dwrTest.getSysFuntions(function (result) {
		
		var funDatas = result.lstResult;
		
		for (var i = 0; i < result.rows; i++) {
		
			var _panel = new Ext.tree.TreePanel({
			
				title: funDatas[i].funName,
				id: funDatas[i].id,
				animate:true,
				enableDD:true,
				containerScroll: true,
				loader: new Ext.tree.TreeLoader({
					
					dataUrl: url + "MenuServlet",
					listeners:{
			            beforeload: function (loader, nodes) {
			            	
			            	loader.baseParams.id = nodes.id;
			            }
					}
				}),
		        root: new Ext.tree.AsyncTreeNode({
		            expanded: true,
		        	id: funDatas[i].id != null ? funDatas[i].id : "root"
		        }),
		        rootVisible: false,
		        listeners: {
		            click: function(n) {
		                Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');
		                
		                Ext.getCmp("tabpanel").add(new Ext.Panel({title: n.attributes.text}));
		            }
		        }
			});
			
			menuPanel.add(_panel);
		}
		
		menuPanel.doLayout(true, true);
	});
	
    var viewport = new Ext.Viewport({
	    layout: 'border',
	    defaults: {
	        activeItem: 0
	    },
	    items: [{
	    	xtype: "panel",
	        region: 'north',
	        collapsible: true,
	        contentEl: "topDiv",
	        height: 120,
	        border: false
	    }, 
	    menuPanel,
	    new Ext.MainInfoPanel()
	    /*{
	        region: 'center',
	        xtype: 'tabpanel',
	        id: "tabpanel",
	        items: {
	            title: 'Default Tab',
	            html: 'The first tab\'s content. Others may be added dynamically'
	        }
	    }, {
	        region: 'south',
	        title: 'Information',
	        collapsible: true,
	        html: 'Information goes here',
	        split: true,
	        height: 100,
	        minHeight: 100
	    }*/]
	});
});